// $ANTLR : "Anasint.g" -> "Anasint.java"$

package pl.prac05;

import antlr.TokenBuffer;
import antlr.TokenStreamException;
import antlr.TokenStreamIOException;
import antlr.ANTLRException;
import antlr.LLkParser;
import antlr.Token;
import antlr.TokenStream;
import antlr.RecognitionException;
import antlr.NoViableAltException;
import antlr.MismatchedTokenException;
import antlr.SemanticException;
import antlr.ParserSharedInputState;
import antlr.collections.impl.BitSet;

public class Anasint extends antlr.LLkParser       implements AnasintTokenTypes
 {

protected Anasint(TokenBuffer tokenBuf, int k) {
  super(tokenBuf,k);
  tokenNames = _tokenNames;
}

public Anasint(TokenBuffer tokenBuf) {
  this(tokenBuf,3);
}

protected Anasint(TokenStream lexer, int k) {
  super(lexer,k);
  tokenNames = _tokenNames;
}

public Anasint(TokenStream lexer) {
  this(lexer,3);
}

public Anasint(ParserSharedInputState state) {
  super(state,3);
  tokenNames = _tokenNames;
}

	public final void entrada() throws RecognitionException, TokenStreamException {
		
		
		declaraciones();
		match(SECCION);
		{
		int _cnt988=0;
		_loop988:
		do {
			if ((_tokenSet_0.member(LA(1)))) {
				regla();
			}
			else {
				if ( _cnt988>=1 ) { break _loop988; } else {throw new NoViableAltException(LT(1), getFilename());}
			}
			
			_cnt988++;
		} while (true);
		}
		{
		switch ( LA(1)) {
		case SECCION:
		{
			match(SECCION);
			usercode();
			break;
		}
		case EOF:
		{
			break;
		}
		default:
		{
			throw new NoViableAltException(LT(1), getFilename());
		}
		}
		}
	}
	
	public final void declaraciones() throws RecognitionException, TokenStreamException {
		
		
		{
		_loop992:
		do {
			if ((LA(1)==ID)) {
				flex_definition();
			}
			else {
				break _loop992;
			}
			
		} while (true);
		}
		{
		if ((LA(1)==PERCENT) && (LA(2)==TOP)) {
			ctop_definitions();
		}
		else if ((LA(1)==NOWRAP||LA(1)==PERCENT||LA(1)==SECCION) && (_tokenSet_1.member(LA(2)))) {
		}
		else {
			throw new NoViableAltException(LT(1), getFilename());
		}
		
		}
		{
		switch ( LA(1)) {
		case PERCENT:
		{
			cdefinitions();
			break;
		}
		case NOWRAP:
		case SECCION:
		{
			break;
		}
		default:
		{
			throw new NoViableAltException(LT(1), getFilename());
		}
		}
		}
		{
		switch ( LA(1)) {
		case NOWRAP:
		{
			match(NOWRAP);
			break;
		}
		case SECCION:
		{
			break;
		}
		default:
		{
			throw new NoViableAltException(LT(1), getFilename());
		}
		}
		}
	}
	
	public final void regla() throws RecognitionException, TokenStreamException {
		
		
		regexp();
		action();
	}
	
	public final void usercode() throws RecognitionException, TokenStreamException {
		
		
		{
		int _cnt1037=0;
		_loop1037:
		do {
			if (((LA(1) >= VOID && LA(1) <= STRING))) {
				function_def();
			}
			else {
				if ( _cnt1037>=1 ) { break _loop1037; } else {throw new NoViableAltException(LT(1), getFilename());}
			}
			
			_cnt1037++;
		} while (true);
		}
	}
	
	public final void flex_definition() throws RecognitionException, TokenStreamException {
		
		
		match(ID);
		regexp();
	}
	
	public final void ctop_definitions() throws RecognitionException, TokenStreamException {
		
		
		match(PERCENT);
		match(TOP);
		match(LLAVE_ABRIR);
		{
		int _cnt999=0;
		_loop999:
		do {
			if ((_tokenSet_2.member(LA(1)))) {
				cdefinition();
			}
			else {
				if ( _cnt999>=1 ) { break _loop999; } else {throw new NoViableAltException(LT(1), getFilename());}
			}
			
			_cnt999++;
		} while (true);
		}
		match(LLAVE_CERRAR);
	}
	
	public final void cdefinitions() throws RecognitionException, TokenStreamException {
		
		
		match(PERCENT);
		match(LLAVE_ABRIR);
		{
		int _cnt1002=0;
		_loop1002:
		do {
			if ((_tokenSet_2.member(LA(1)))) {
				cdefinition();
			}
			else {
				if ( _cnt1002>=1 ) { break _loop1002; } else {throw new NoViableAltException(LT(1), getFilename());}
			}
			
			_cnt1002++;
		} while (true);
		}
		match(PERCENT);
		match(LLAVE_CERRAR);
	}
	
	public final void regexp() throws RecognitionException, TokenStreamException {
		
		
		reg();
		{
		switch ( LA(1)) {
		case CADENA:
		case PARENTESIS_ABRIR:
		case LLAVE_ABRIR:
		case CORCHETE_ABRIR:
		case OR:
		{
			{
			switch ( LA(1)) {
			case OR:
			{
				match(OR);
				break;
			}
			case CADENA:
			case PARENTESIS_ABRIR:
			case LLAVE_ABRIR:
			case CORCHETE_ABRIR:
			{
				break;
			}
			default:
			{
				throw new NoViableAltException(LT(1), getFilename());
			}
			}
			}
			regexp();
			break;
		}
		case RETURN:
		case NOWRAP:
		case ID:
		case PERCENT:
		case SECCION:
		case PARENTESIS_CERRAR:
		{
			break;
		}
		default:
		{
			throw new NoViableAltException(LT(1), getFilename());
		}
		}
		}
	}
	
	public final void cdefinition() throws RecognitionException, TokenStreamException {
		
		
		{
		if (((LA(1) >= VOID && LA(1) <= STRING))) {
			tipo();
			match(ID);
		}
		else if ((LA(1)==INCLUDE) && (LA(2)==MENOR)) {
			match(INCLUDE);
			match(MENOR);
			match(ID);
			match(MAYOR);
		}
		else if ((LA(1)==INCLUDE) && (LA(2)==CADENA)) {
			match(INCLUDE);
			match(CADENA);
		}
		else {
			throw new NoViableAltException(LT(1), getFilename());
		}
		
		}
		match(SEMICOLON);
	}
	
	public final void tipo() throws RecognitionException, TokenStreamException {
		
		
		switch ( LA(1)) {
		case INT:
		{
			match(INT);
			break;
		}
		case CHAR:
		{
			match(CHAR);
			break;
		}
		case FLOAT:
		{
			match(FLOAT);
			break;
		}
		case DOUBLE:
		{
			match(DOUBLE);
			break;
		}
		case STRING:
		{
			match(STRING);
			break;
		}
		case VOID:
		{
			match(VOID);
			break;
		}
		default:
		{
			throw new NoViableAltException(LT(1), getFilename());
		}
		}
	}
	
	public final void action() throws RecognitionException, TokenStreamException {
		
		
		{
		if ((LA(1)==ID) && (LA(2)==ASIGNACION)) {
			asignacion();
		}
		else if ((LA(1)==ID) && (LA(2)==INC||LA(2)==DEC)) {
			incdec();
		}
		else if ((LA(1)==RETURN)) {
			match(RETURN);
			{
			switch ( LA(1)) {
			case ID:
			{
				match(ID);
				break;
			}
			case NUM_INTEGER:
			{
				match(NUM_INTEGER);
				break;
			}
			case TRUE:
			{
				match(TRUE);
				break;
			}
			case FALSE:
			{
				match(FALSE);
				break;
			}
			default:
			{
				throw new NoViableAltException(LT(1), getFilename());
			}
			}
			}
		}
		else if ((LA(1)==ID) && (LA(2)==PARENTESIS_ABRIR)) {
			function_statement();
		}
		else {
			throw new NoViableAltException(LT(1), getFilename());
		}
		
		}
		match(SEMICOLON);
	}
	
	public final void reg() throws RecognitionException, TokenStreamException {
		
		
		switch ( LA(1)) {
		case CORCHETE_ABRIR:
		{
			rango();
			break;
		}
		case LLAVE_ABRIR:
		{
			conjunto();
			break;
		}
		case PARENTESIS_ABRIR:
		{
			parentado();
			break;
		}
		case CADENA:
		{
			match(CADENA);
			break;
		}
		default:
		{
			throw new NoViableAltException(LT(1), getFilename());
		}
		}
	}
	
	public final void rango() throws RecognitionException, TokenStreamException {
		
		
		match(CORCHETE_ABRIR);
		{
		switch ( LA(1)) {
		case ID:
		{
			match(ID);
			break;
		}
		case NUM_INTEGER:
		{
			match(NUM_INTEGER);
			break;
		}
		default:
		{
			throw new NoViableAltException(LT(1), getFilename());
		}
		}
		}
		{
		int _cnt1017=0;
		_loop1017:
		do {
			if ((LA(1)==MENOS)) {
				match(MENOS);
				{
				switch ( LA(1)) {
				case ID:
				{
					match(ID);
					break;
				}
				case NUM_INTEGER:
				{
					match(NUM_INTEGER);
					break;
				}
				default:
				{
					throw new NoViableAltException(LT(1), getFilename());
				}
				}
				}
			}
			else {
				if ( _cnt1017>=1 ) { break _loop1017; } else {throw new NoViableAltException(LT(1), getFilename());}
			}
			
			_cnt1017++;
		} while (true);
		}
		match(CORCHETE_CERRAR);
		cierre();
	}
	
	public final void conjunto() throws RecognitionException, TokenStreamException {
		
		
		match(LLAVE_ABRIR);
		{
		switch ( LA(1)) {
		case ID:
		{
			match(ID);
			break;
		}
		case NUM_INTEGER:
		{
			match(NUM_INTEGER);
			break;
		}
		default:
		{
			throw new NoViableAltException(LT(1), getFilename());
		}
		}
		}
		match(LLAVE_CERRAR);
		cierre();
	}
	
	public final void parentado() throws RecognitionException, TokenStreamException {
		
		
		match(PARENTESIS_ABRIR);
		regexp();
		match(PARENTESIS_CERRAR);
		cierre();
	}
	
	public final void cierre() throws RecognitionException, TokenStreamException {
		
		
		{
		switch ( LA(1)) {
		case ASTERISCO:
		{
			match(ASTERISCO);
			break;
		}
		case MAS:
		{
			match(MAS);
			break;
		}
		case QUESTION:
		{
			match(QUESTION);
			break;
		}
		case RETURN:
		case NOWRAP:
		case ID:
		case CADENA:
		case PERCENT:
		case SECCION:
		case PARENTESIS_ABRIR:
		case PARENTESIS_CERRAR:
		case LLAVE_ABRIR:
		case CORCHETE_ABRIR:
		case OR:
		{
			break;
		}
		default:
		{
			throw new NoViableAltException(LT(1), getFilename());
		}
		}
		}
	}
	
	public final void asignacion() throws RecognitionException, TokenStreamException {
		
		
		match(ID);
		match(ASIGNACION);
		valor();
	}
	
	public final void incdec() throws RecognitionException, TokenStreamException {
		
		
		match(ID);
		{
		switch ( LA(1)) {
		case INC:
		{
			match(INC);
			break;
		}
		case DEC:
		{
			match(DEC);
			break;
		}
		default:
		{
			throw new NoViableAltException(LT(1), getFilename());
		}
		}
		}
	}
	
	public final void function_statement() throws RecognitionException, TokenStreamException {
		
		
		match(ID);
		match(PARENTESIS_ABRIR);
		{
		switch ( LA(1)) {
		case ID:
		case CADENA:
		{
			params_statement();
			break;
		}
		case PARENTESIS_CERRAR:
		{
			break;
		}
		default:
		{
			throw new NoViableAltException(LT(1), getFilename());
		}
		}
		}
		match(PARENTESIS_CERRAR);
	}
	
	public final void valor() throws RecognitionException, TokenStreamException {
		
		
		switch ( LA(1)) {
		case NUM_INTEGER:
		{
			match(NUM_INTEGER);
			break;
		}
		case NUM_REAL:
		{
			match(NUM_REAL);
			break;
		}
		case CADENA:
		{
			match(CADENA);
			break;
		}
		case ID:
		{
			function_statement();
			break;
		}
		default:
		{
			throw new NoViableAltException(LT(1), getFilename());
		}
		}
	}
	
	public final void params_statement() throws RecognitionException, TokenStreamException {
		
		
		param_stat();
		{
		_loop1032:
		do {
			if ((LA(1)==COMA)) {
				match(COMA);
				param_stat();
			}
			else {
				break _loop1032;
			}
			
		} while (true);
		}
	}
	
	public final void param_stat() throws RecognitionException, TokenStreamException {
		
		
		switch ( LA(1)) {
		case ID:
		{
			match(ID);
			{
			switch ( LA(1)) {
			case CORCHETE_ABRIR:
			{
				match(CORCHETE_ABRIR);
				match(NUM_INTEGER);
				match(CORCHETE_CERRAR);
				break;
			}
			case COMA:
			case PARENTESIS_CERRAR:
			{
				break;
			}
			default:
			{
				throw new NoViableAltException(LT(1), getFilename());
			}
			}
			}
			break;
		}
		case CADENA:
		{
			match(CADENA);
			break;
		}
		default:
		{
			throw new NoViableAltException(LT(1), getFilename());
		}
		}
	}
	
	public final void function_def() throws RecognitionException, TokenStreamException {
		
		
		tipo();
		match(ID);
		match(PARENTESIS_ABRIR);
		{
		if (((LA(1) >= VOID && LA(1) <= STRING)) && (LA(2)==ID||LA(2)==ASTERISCO)) {
			params_def();
		}
		else if ((LA(1)==VOID) && (LA(2)==PARENTESIS_CERRAR)) {
			match(VOID);
		}
		else if ((LA(1)==PARENTESIS_CERRAR)) {
		}
		else {
			throw new NoViableAltException(LT(1), getFilename());
		}
		
		}
		match(PARENTESIS_CERRAR);
		match(LLAVE_ABRIR);
		{
		int _cnt1041=0;
		_loop1041:
		do {
			if ((LA(1)==RETURN||LA(1)==ID)) {
				action();
			}
			else {
				if ( _cnt1041>=1 ) { break _loop1041; } else {throw new NoViableAltException(LT(1), getFilename());}
			}
			
			_cnt1041++;
		} while (true);
		}
		match(LLAVE_CERRAR);
	}
	
	public final void params_def() throws RecognitionException, TokenStreamException {
		
		
		def_par();
		{
		_loop1044:
		do {
			if ((LA(1)==COMA)) {
				match(COMA);
				def_par();
			}
			else {
				break _loop1044;
			}
			
		} while (true);
		}
	}
	
	public final void def_par() throws RecognitionException, TokenStreamException {
		
		
		tipo();
		{
		switch ( LA(1)) {
		case ASTERISCO:
		{
			match(ASTERISCO);
			break;
		}
		case ID:
		{
			break;
		}
		default:
		{
			throw new NoViableAltException(LT(1), getFilename());
		}
		}
		}
		match(ID);
		{
		switch ( LA(1)) {
		case CORCHETE_ABRIR:
		{
			match(CORCHETE_ABRIR);
			match(CORCHETE_CERRAR);
			break;
		}
		case COMA:
		case PARENTESIS_CERRAR:
		{
			break;
		}
		default:
		{
			throw new NoViableAltException(LT(1), getFilename());
		}
		}
		}
	}
	
	
	public static final String[] _tokenNames = {
		"<0>",
		"EOF",
		"<2>",
		"NULL_TREE_LOOKAHEAD",
		"NUM_REAL",
		"NUM_INTEGER",
		"\"void\"",
		"\"int\"",
		"\"char\"",
		"\"float\"",
		"\"double\"",
		"\"string\"",
		"\"true\"",
		"\"false\"",
		"\"if\"",
		"\"while\"",
		"\"for\"",
		"\"do\"",
		"\"return\"",
		"\"#include\"",
		"\"top\"",
		"\"%option noyywrap\"",
		"NUEVA_LINEA",
		"BLANCO",
		"DIGITO",
		"NUMERO",
		"LETRA",
		"ID",
		"CADENA",
		"COMILLAS",
		"PERCENT",
		"SECCION",
		"PUNTO",
		"COLON",
		"SEMICOLON",
		"COMA",
		"ASIGNACION",
		"PARENTESIS_ABRIR",
		"PARENTESIS_CERRAR",
		"LLAVE_ABRIR",
		"LLAVE_CERRAR",
		"CORCHETE_ABRIR",
		"CORCHETE_CERRAR",
		"MENOR",
		"MAYOR",
		"NEGACION",
		"NO_IGUAL",
		"MENOR_IGUAL",
		"MAYOR_IGUAL",
		"QUESTION",
		"AMP",
		"MAS",
		"MENOS",
		"ASTERISCO",
		"DIV",
		"OR",
		"INC",
		"DEC",
		"COMENTARIO"
	};
	
	private static final long[] mk_tokenSet_0() {
		long[] data = { 2886486458368L, 0L};
		return data;
	}
	public static final BitSet _tokenSet_0 = new BitSet(mk_tokenSet_0());
	private static final long[] mk_tokenSet_1() {
		long[] data = { 2888633942016L, 0L};
		return data;
	}
	public static final BitSet _tokenSet_1 = new BitSet(mk_tokenSet_1());
	private static final long[] mk_tokenSet_2() {
		long[] data = { 528320L, 0L};
		return data;
	}
	public static final BitSet _tokenSet_2 = new BitSet(mk_tokenSet_2());
	
	}
